package com._51doit.spark03

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object MapTest {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName(this.getClass.getSimpleName)
    val sc: SparkContext = new SparkContext(conf)

    val rdd1: RDD[Int] = sc.makeRDD(List(1,3,5,7,9,12),2)
    rdd1.map(t=>t*2)

val f2 =(it:Iterator[Int])=>it.map(t=>t*2)

    val res: RDD[Int] = rdd1.mapPartitions(f2)


    val f3=(i:Int,it:Iterator[Int])=>{
      it.map(t=>s"v-${t},p-${i}")

    }

    val res1: RDD[String] = rdd1.mapPartitionsWithIndex(f3)

res1.foreach(println)

  }



}
